Passed
Pull Request — master (#39)
by Michael
02:36
created

T_IDENTIFIER ➔ ???   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 1
rs 10
1
jQuery(function initializeProsemirror() {
2
3
    const $toggleEditorButton = jQuery('.plugin_prosemirror_useWYSIWYG');
4
    $toggleEditorButton.on('click', function() {
5
        const $current = DokuCookie.getValue('plugin_prosemirror_useWYSIWYG');
0 ignored issues
show
Bug introduced by
The variable DokuCookie seems to be never declared. If this is a global, consider adding a /** global: DokuCookie */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
6
        DokuCookie.setValue('plugin_prosemirror_useWYSIWYG', $current ? '' : '1');
7
    });
8
9
    const $jsonField = jQuery('#dw__editform').find('[name=prosemirror_json]');
10
    if (!$jsonField.length) {
11
        return;
12
    }
13
    $jsonField.attr('id', 'prosemirror_json');
14
15
    try {
0 ignored issues
show
Unused Code introduced by
Empty try statement found. This statement can be removed.
Loading history...
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
16
        /* DOKUWIKI:include lib/bundle.js */
17
    } catch (e) {
0 ignored issues
show
introduced by
This code is unreachable and can thus be removed without consequences.
Loading history...
18
        const $textArea = jQuery('#wiki__text');
0 ignored issues
show
Bug introduced by
The variable $textArea seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.$textArea.
Loading history...
19
        let message = 'There was an error in the WYSIWYG editor. You will be redirected to the syntax editor in 5 seconds.';
0 ignored issues
show
Bug introduced by
The variable message seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.message.
Loading history...
20
        if (window.SentryPlugin) {
21
            SentryPlugin.logSentryException(e, {
22
                tags: {
23
                    plugin: 'prosemirror',
24
                    'id': JSINFO.id,
25
                },
26
                extra: {
27
                    'content': $textArea.val(),
28
                }
29
            });
30
            message += ' The error has been logged to sentry.';
31
        }
32
        $textArea.replaceWith('<div class="error">'+ message + '</div>');
33
        setTimeout(function() {
34
            $toggleEditorButton.click();
0 ignored issues
show
Bug introduced by
The variable $toggleEditorButton seems to be never declared. If this is a global, consider adding a /** global: $toggleEditorButton */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
35
        }, 5000);
36
        return;
37
    }
38
39
    jQuery('#wiki__text').hide();
40
    jQuery('#size__ctl').hide();
41
    jQuery('.editBox > .toolbar').hide();
42
});
43